package com.web.index.ao.impl;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;







import org.springframework.stereotype.Service;

import com.base.app.entity.Article;
import com.base.app.service.ArticleService;
import com.base.kongjian.entity.Weibo;
import com.base.kongjian.service.WeiboService;
import com.base.user.entity.Member;
import com.base.user.service.MemberService;
import com.mysteel.page.Page;
import com.web.index.ao.IndexAo;

@Service("indexAo")
public class IndexAoImpl implements IndexAo
{
	@Autowired
	private WeiboService weiboService;
	@Autowired
	private ArticleService articleService;
	@Autowired
	private MemberService memberService;
	

	@Override
	public Page<?> search(String keywork, int type, HttpServletRequest request)
	{
		//type=1:΢��type=2����Աtype=3������
		Map<String, Object> params = new HashMap<String, Object>();
		if(type==1)
		{
			params.put ("title" ,"%"+keywork+"%");
			Page<Weibo> page = weiboService.queryWeibo (params ,0 ,-1);
			
			return page;
		}
		
		if(type==2)
		{
			params.put ("nickName" ,"%"+keywork+"%");
			Page<Member> page = memberService.queryMember (params ,0 ,-1);
			
			return page;
		}
		
		if(type==3)
		{
			params.put ("title" ,"%"+keywork+"%");
			Page<Article> page = articleService.queryArticle  (params ,0 ,-1);
			
			return page;	
		}
		
		return null;
	}
	
}
